<?php

class ControllerWpPage extends Controller
{
    private $error = array();

    public function getMyPages()
    {
        $this->load->model('wp/page');
        if (! $this->actionCheck(true, false)) {
            return;
        }
        
		
		$data = $this->model_wp_page->getMyPages( $this->customer->getId(),
					$this->request->get['pageNum'],$this->request->get['pageSize']);

        $this->load->model('tool/image');
        foreach ($data as &$item){
            if(empty($item['thumb'])){
                $item['thumb'] = $this->model_tool_image->resize('no_image.png', 100, 100);
            }
            else{
                $item['thumb'] = $this->model_tool_image->resize($item['thumb'], 100, 100);
            }

        }

		$this->response->setOK( $data);
    }

	public function Page()
    {
        $this->load->model('wp/page');
        if (! $this->actionCheck(true, false)) {
            return;
        }
        
		
		$data = $this->model_wp_page->getPage($this->customer->getId(),$this->request->get['id']);
		$this->response->setOK( $data);
		
    }

    public function unReadCount()
    {
        $this->load->model('wp/page');
        if (! $this->actionCheck(true, false)) {
            return;
        }


        $data = $this->model_wp_page->unReadCount($this->customer->getId());
        $this->response->setOK( $data);

    }


	public function UserList()
    {
        $this->load->model('wp/page');
        if (! $this->actionCheck(false, false)) {
            return;
        }
        
		
		$data = $this->model_wp_page->getUserList();
		$this->response->setOK( $data);
		
    }

    public function Comment()
    {
        $this->load->model('wp/page');
        if (! $this->actionCheck(true, true)) {
            return;
        }


        $this->model_wp_page->comment($this->request->post['page_id'],$this->request->post['message'],
            $this->customer->getId(),$this->customer->getFirstName());
        $this->response->setOK( );

    }
	
}